package queries;

/**
 * @author KRISTHI@N
 *
 */

import java.sql.SQLException;
import javax.swing.JOptionPane;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;
import com.mysql.jdbc.Statement;


public class Insert
{
    ConnectionJDBC connetionJDBC; 
    Connection connection;
    private boolean bError = false;
    
    public void insertData(String consulta)
    {
        connetionJDBC = new ConnectionJDBC();
        connection = (Connection) connetionJDBC.getConexion();
        
        try 
        {
        	Statement estamentoPreparado=(PreparedStatement) connection.prepareStatement(consulta);  
        	estamentoPreparado.executeUpdate(consulta);
        } 
        catch (com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException ex) 
		{   
			bError=true;
		}
		catch (SQLException ex) 
		{   
			JOptionPane.showMessageDialog(null,"no pudo buscar");
			ex.printStackTrace();
		}
	}
    
    public boolean retornarError()
	{
		return bError;
	}
}
